package com.yuanian.wf.pojo.model;

import com.yuanian.wf.event.Event;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
 * WfProcessAction注解对应的管理类
 */
public class ProcessAction {

    //参数类型
    private Class<? extends Event> wfEvent;
    //是否异步
    private boolean async;
    //和流程相关为null
    private String taskKey;
    //类上的管理
    private ProcessKey process;
    //注解对应要执行的方法
    private Method method;

    public ProcessAction(Class<? extends Event> wfEvent, boolean async, String taskKey, ProcessKey process, Method method) {
        this.wfEvent = wfEvent;
        this.async = async;
        this.taskKey = taskKey;
        this.process = process;
        this.method = method;
    }

    /**
     * 反射的方法调用
     * @param obj
     * @param event
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     */
    public void invoke(Object obj, Event event) throws InvocationTargetException, IllegalAccessException {
        method.invoke(obj, event);
    }

    public Class<? extends Event> getWfEvent() {
        return wfEvent;
    }

    public boolean isAsync() {
        return async;
    }

    public void setAsync(boolean async) {
        this.async = async;
    }

    public String getTaskKey() {
        return taskKey;
    }

    public void setTaskKey(String taskKey) {
        this.taskKey = taskKey;
    }

    public ProcessKey getProcess() {
        return process;
    }

    public void setProcess(ProcessKey process) {
        this.process = process;
    }

    public void setWfEvent(Class<? extends Event> wfEvent) {
        this.wfEvent = wfEvent;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }
}
